faf0f5
@@ -41,6 +41,7 @@
public class DriverRegistryImpl implements DriverRegistry {
 
     private final Map<String ,HashMap<String, InstalledDriver>> drivers = new HashMap<>();
 
+    //default profile is used for standalone and for hot deployed driver in domain mode
     private static final String DEFAULT_PROFILE = "default";
 
     @Override
@@ -84,19 +85,44 @@
public class DriverRegistryImpl implements DriverRegistry {
 
     @Override
     public Set<InstalledDriver> getInstalledDrivers(String profileName) {
-        String profile = profileName != null ? profileName : DEFAULT_PROFILE;
-        if (drivers.get(profile) == null) {
-            throw ROOT_LOGGER.noDriverDefinedInDefaultProfile();
+        Set<InstalledDriver> installedDrivers = new HashSet<>();
+        synchronized (drivers) {
+            if (profileName != null) {
+                if (drivers.get(profileName) != null) {
+                    installedDrivers.addAll(drivers.get(profileName).values());
+                }
+            } else {
+                if (drivers.get(DEFAULT_PROFILE) == null) {
+                    throw ROOT_LOGGER.noDriverDefinedInDefaultProfile();
+                }
+            }
+
+            if (drivers.get(DEFAULT_PROFILE) != null) {
+                installedDrivers.addAll(drivers.get(DEFAULT_PROFILE).values());
+            }
         }
-        return Collections.unmodifiableSet(Collections.synchronizedSet(new HashSet<InstalledDriver>(drivers.get(profile).values())));
+
+        return Collections.unmodifiableSet(installedDrivers);
     }
 
     @Override
     public InstalledDriver getInstalledDriver(String name, String profileName) throws IllegalStateException {
-        String profile = profileName != null ? profileName : DEFAULT_PROFILE;
-        if (drivers.get(profile) == null) {
-            throw ROOT_LOGGER.driverNotDefinedInDefaultProfile(name);
+        InstalledDriver returnValue = null;
+        synchronized (drivers) {
+            if (profileName != null) {
+                if (drivers.get(profileName) != null) {
+                    returnValue = drivers.get(profileName).get(name);
+                }
+            } else {
+                if (drivers.get(DEFAULT_PROFILE) == null) {
+                    throw ROOT_LOGGER.driverNotDefinedInDefaultProfile(name);
+                }
+            }
+
+            if (returnValue == null) {
+                returnValue = drivers.get(DEFAULT_PROFILE).get(name);
+            }
         }
-        return drivers.get(profile).get(name);
+        return returnValue;
     }
 }
